﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AspNetCs.Common;

public partial class AjaxXml_UpdateVideoAccessCount : Admin_BasePage
{
    private int AccessCount = 0;
    private int Id = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        IsExit();
        if (!IsPostBack)
        {
            GetParas();
            bool bo = EditVideoAccessCount();
            if (bo)
            {
                Response.Write("OK");
            }
            else
            {
                Response.Write("Error");
            }
            Response.End();
        }

    }

    /// <summary>
    /// 获得参数
    /// </summary>
    private void GetParas()
    {
        if (string.IsNullOrEmpty(Request["Id"]) || string.IsNullOrEmpty(Request["AccessCount"]))
        {
            //Response.Redirect(configInfo.InstallDir+"Master/Admin_login.Aspx");
            Response.Write("Error");
            Response.End();
        }
        else
        {
            AccessCount = StringHelper.isNumber_int(Request.QueryString["AccessCount"]);
            Id = StringHelper.isNumber_int(Request.QueryString["Id"]);
        }

    }

    /// <summary>
    /// 修改视频访问量
    /// </summary>
    /// <returns></returns>
    private bool EditVideoAccessCount()
    {
        int re = 0;
        string cmdText = "update video set hot={0} where Id={1}";
        cmdText = string.Format(cmdText, AccessCount, Id);
        dbclass db = new dbclass();
        re = db.ExecuteReRow_SQL(cmdText);
        return re > 0 ? true : false;
    }

}
